
$(document).ready(function() {

  $.ajaxSetup({
    url: '../ajax.php',
    global: true,
    type: "POST"
  });
  
  
  
  $('#login-link').click(function() {
    $('#login-form').toggle('slow', function() {
      // Animation complete.
    });
  });  
  
  
  
  $('#reg-link').click(function() {
    $('#reg-form').toggle('slow', function() {
      // Animation complete.
    });
  });  
  
  
  
  $('#edit-data').click(function() {
    $.post("/ajax.php", { "ajax":"1", "get":"personal form" }, function(data) {
      $('#personal-information').html(data);
    });
  });
  
  
  
  $('#change-passwd').click(function() {
    $.post("/ajax.php", { "ajax":"1", "get":"change passwd form" }, function(data) {
      $('#personal-information').html(data);
    });
  });
  
  
  
  $('#add-machine').click(function() {
    $.post("/ajax.php", { "ajax":"1", "get":"add machine form" }, function(data) {
      $('#machines-information').html(data);
    });
  });
  
  
  
});

function EditMachine(id) {
  $.post("/ajax.php", { "ajax":"1", "get":"edit machine form", "machineid":id }, function(data) {
    $('#machines-information').html(data);
  });
}

function DeleteMachine(id) {
  location.href='/profile/delete/'+id+'.html';
}

function RemoveOpenID(id) {
  location.href='/profile/openiddel/'+id+'.html';
}

function commafy(val) {
  var pos;
  val=val.split(",").join("");   // remove existing commas if present.
  var dot=val.indexOf(".");      // locate decmal
  if(dot<0)dot=val.length;       // use end if no decimal
  var r="";
  for(pos=dot-3;pos>=1;pos-=3)   // put commas in
    r=","+val.substr(pos,3)+r;
    r=val.substring(0,pos+3)+r;    // put start of string on
    return r;
}



